/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dpy.appmvdpy.Models.Importers;

import com.dpy.appmvdpy.Facades.UsersFacade;
import com.dpy.appmvdpy.Models.Clientes;
import com.dpy.appmvdpy.Models.Produtos;
import com.dpy.appmvdpy.Models.Vendedor;
import java.io.File;
import java.io.IOException;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

/**
 *
 * @author ac_psoares
 */
@Component
@Scope(value="request")
public class VendedorImporter extends Importer<Vendedor> {

    
    public VendedorImporter()
    {
  
    }
    
    public VendedorImporter(File file)
    {
      super(file);
    }
    
    @Override
    public List<Vendedor> doImport() {
       List<Vendedor> retorno = new ArrayList<Vendedor>();
        try {
            
           int i = 0;
           String record = null;
    
           while((record = bReader.readLine()) != null)
           {
               if (record.length() < 1) continue;   
            Vendedor p = new Vendedor();   

            System.out.println("registro :" + record);
            String[] parametros = record.split("##");
            p.setCodigoDPY(parametros[0].trim());  
            p.setNome(parametros[1].trim());
            p.setInicioFaixaCadastro(new Integer(0));
            p.setFimFaixaCadastro(new Integer(0));
            p.setUserId(null);
            p.setIntegrado(true);
            retorno.add(p);
  
           }
        } catch (IOException ex) {
            Logger.getLogger(ClientImporter.class.getName()).log(Level.SEVERE, null, ex);
        }
        return retorno;    
    }
    
}
